﻿using System.ComponentModel.DataAnnotations;

namespace ShanNiang.Hosting.Common
{
    /// <summary>
    /// 分页请求基类
    /// </summary>
    public abstract class PageRequest : RequestBase, IPageRequest
    {
        /// <summary>
        /// 页码
        /// </summary>
        [Required(ErrorMessage = "页码不能为空")]
        [Range(1, int.MaxValue, ErrorMessage = " PageIndex Out of range.")]
        public int PageIndex { get; set; }

        /// <summary>
        /// 每页条数
        /// </summary>
        [Required(ErrorMessage = "数据条数不能为空")]
        [Range(0, int.MaxValue, ErrorMessage = " PageSize Out of range.")]
        public int PageSize { get; set; }

        public int Skip => (PageIndex - 1) * PageSize;

    }
}
